<template>
  <div>
    <el-table v-loading="loading" :data="tableData" style="width: 100%" @sort-change="sortChange">
      <el-table-column prop="name" label="企业名称">
        <template slot-scope="scope">
          <p class="tit" @click="toDetail(scope.row)">{{ scope.row.name }}</p>
        </template>
      </el-table-column>
      <el-table-column
        prop="pingfen"
        label="科研创新技数"
        width="180"
        sortable="custom"
      ></el-table-column>
      <el-table-column prop="oper_name" label="法人代表" width="180">
      </el-table-column>
      <el-table-column prop="regist_capi" label="注册资金" sortable width="180">
        <template slot-scope="scope">{{ scope.row.regist_capi_new }}</template>
      </el-table-column>
      <el-table-column prop="start_date" label="注册时间" sortable width="180">
      </el-table-column>
      <el-table-column prop="address" label="通讯地址">
        <template slot-scope="scope">
          <p class="weight">{{ scope.row.address }}</p>
        </template>
      </el-table-column>
      <el-table-column prop="industry_label" label="企业标签">
        <template slot-scope="scope">
          <p class="weight industry-label">
            {{
              scope.row.industry_label && scope.row.industry_label.join("，")
            }}
          </p>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      layout="prev, pager, next"
      :total="total"
      :page-size="pageSize"
      :current-page.sync="pageNum"
      @current-change="getOneCurrentPage"
      class="el-pagination"
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  props: {
    targetCode: {
      type: String,
    },
  },
  data() {
    return {
      tableData: [],
      pageSize: 10,
      pageNum: 1,
      total: 0,
      sort: 1,
      sortField: "pingfen",
      activeIndex: "1",
      loading: false,
    };
  },
  mounted() {
    this.getCompanyInfo(this.targetCode);
  },
  methods: {
    getCompanyInfo(code) {
      this.loading = true;
      const params = {
        ipi: this.pageNum,
        ips: this.pageSize,
        code: code,
        sortField: this.sortField,
        sort: this.sort,
      };
      this.$get(this.$Url.industrial.companyList, params).then((res) => {
        this.tableData = res.data.result;
        this.pageNum = res.data.pageNum;
        this.pageSize = res.data.pageSize;
        this.total = res.data.total;
         this.loading = false;
      });
    },
    // 监听排序，对专利评分进行自定义排序
    sortChange(e) {
      this.sort = e.order === "ascending" ? 1 : 0;
      this.sortField = e.prop;
      this.getCompanyInfo(this.targetCode);
    },
    getOneCurrentPage(val) {
      this.pageNum = val;
      this.getCompanyInfo(this.targetCode);
    },
    handleSelect(item) {
      this.activeIndex = item;
    },
  },
};
</script>

<style lang="scss" scoped>
.panel2 {
  position: relative;
  width: 100%;
  background: #fff;
  padding-bottom: 20px;
  .el-pagination {
    margin-top: 10px;
    text-align: center;
  }
}
</style>